package com.shujia.java.day18.demo10;

/**
 * @Description: MyThreadDemo 我必须想让李四运行完
 * @Author: 王火火
 * @Date: 2019/8/20 11:07
 * <p>
 * 1.继承Thread
 * 2.重写run
 * 3.new 对象
 * 4.启动
 * <p>
 * 线程的中断
 */

public class MyThreadDemo extends Thread {
    @Override
    public void run() {
        Thread thread = Thread.currentThread();
        for (int i = 0; i < 100; i++) {
            if(getName().equals("张三")&&i==45){
                try {
                    System.out.println(thread.getName());
                    thread.join(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(getName() + "------------"+i );
        }

    }
}
